{% extends "base.html" %}
{% import "macros_modal.html" as modal_macros %}
{% block body %}
<div class="contact-info">

    <div class="row">
        <!--<div class="col_1_of_bottom span_1_of_first1">-->

        <div class="col-sm-2">
            <h4>Analytics
            </h4>
            <div class="extra-wrap">
                <table>
                {% for star, count, per in siteinfo.per_star_count() %}
                    <tr>
                        <td width="40px">{{star}}星:</td>
                        <td width="60px">{{count}}</td>
                        <td width="60px">{{per}}%</td>
                    </tr>
                {% endfor %}
                </table>
            </div>
        </div>

        <div class="col-sm-2">
            <h4>待导入 <input type="button" class="btn btn-success btn-xs" value="refresh" id="refresh_temp_info"></h4>

                <div class="extra-wrap work_page">
                    <p><i class="fa fa-file-image-o"></i> 图片：<a href="{{url_for('work.temp_pics')}}"><span id="temp_file_count">{{ siteinfo.count_temp() }}</span></a></p>
                    <p><i class="fa fa-recycle"></i> 回收站：<a href="{{url_for('work.recycle')}}"><span id="recycle_file_count">{{ siteinfo.count_recycle() }}</span></a></p>
                </div>
        </div>

        <div class="col-sm-2">
            <h4>相册和标签
                <input type="button" class="btn btn-xs btn-success" data-toggle="modal" data-target="#album_modal" value="create">
            </h4>
            <div class="extra-wrap work_page">
                <p><i class="fa fa-newspaper-o"></i> <a href="{{url_for('pic.albums')}}">{{ siteinfo.album_count }}</a>个相册</p>
                <p><i class="fa fa fa-th-large"></i> <a href="{{url_for('pic.volumes')}}">{{ siteinfo.volume_count }}</a>个卷</p>
                <p><i class="fa fa-tags"></i> <a href="{{url_for('pic.tags')}}">{{ siteinfo.tag_count }}</a>个标签</p>
                <p><i class="fa fa-user"></i> <a href="{{url_for('pic.actresses')}}">{{ siteinfo.actress_count }}</a>个模特</p>
                <p><input type="button" class="btn btn-sm btn-info" value="清除缓存" id="cache_clear_btn"></p>
            </div>
        </div>

        <div class="col-sm-2">
            <h4>Settings
                <input type="button" class="btn btn-xs btn-success" data-toggle="modal" data-target="#edit_setting" value="edit">
            </h4>
            <div class="extra-wrap work_page">
                <p>
                    {% for se in settings %}
                        {{se.desc}}  {{se.value}}<br>
                    {% endfor %}
                </p>
            </div>
        </div>



        <div class="col-sm-4">
            <h4>检查文件 <input type="button" class="btn btn-success btn-xs" value="check" id="check_files_btn"></h4>

                <div class="extra-wrap work_page">
                    <p class="small">检查时间：{{checkinfo.check_task_checktime()}}</p>
                    <p><i class="fa fa-file-image-o"></i> 图片数量:  数据库{{ siteinfo.pic_count }} |  文件{{checkinfo.check_task_pics_count()}} | 缩略图 {{checkinfo.check_task_thumbnail_count()}}</p>
                    <p><i class="fa fa-info-circle"></i> <a href="{{url_for('pic.explore',unfiled=true,clear=1 )}}">{{checkinfo.check_tasks_unfiled_pic_count()}}</a>张图片没有加入相册/标签</p>

                    {% if checkinfo.check_task_dbr_lost_count() and checkinfo.check_task_dbr_lost_count() != '0' %}
                    <p><i class="fa fa-window-close"></i> <a href="{{url_for('work.db_lost_pic')}}">{{checkinfo.check_task_dbr_lost_count()}}</a> 张图片 文件存在，没有数据库记录 <input type="button" class="btn btn-xs btn-success" value="移至回收站" id="move_to_recycle_btn"></p>
                    {% endif %}

                    {% if checkinfo.check_task_file_lost_db_count() and checkinfo.check_task_file_lost_db_count() != '0' %}
                    <p><i class="fa fa-window-close"></i> <a href="{{url_for('work.file_lost_pic')}}">{{checkinfo.check_task_file_lost_db_count()}}</a> 张图片 有数据库记录，文件不存在</p>
                    {% endif %}

                    {% if checkinfo.check_task_thumbnail_lost_count() and checkinfo.check_task_thumbnail_lost_count() != '0' %}
                    <p><i class="fa fa-window-close"></i> <a href="{{url_for('work.thumbnail_lost_pic')}}">{{checkinfo.check_task_thumbnail_lost_count()}}</a> 张图片缺少缩略图 <input type="button" class="btn btn-xs btn-success" value="生成缩略图" id="create_thumbnail_btn"></p>
                    {% endif %}

                    {% if checkinfo.check_task_file_lost_thumbnail_count() and checkinfo.check_task_file_lost_thumbnail_count() != '0' %}
                    <p><i class="fa fa-window-close"></i> <a href="{{url_for('work.file_lost_thumbnail')}}">{{checkinfo.check_task_file_lost_thumbnail_count()}}</a> 张缩略图缺失对应的图片 <input type="button" class="btn btn-xs btn-success" value="删除缩略图" id="delete_thumbnail_btn"></p>
                    {% endif %}

                </div>

        </div>
    </div>
    <br>
    <div class="row">

        <div class="col-sm-3">
            <h4>Download from url</h4>
            <div class="extra-wrap work_page">
                <form class="form-horizontal">
                    <div class="form-group">
                        <div class="col-sm-12 col-xs-12">
                            <label for="external_image_url" class="label-control col-sm-2 col-xs-3">URL</label>
                            <div class="col-sm-10 col-xs-9">
                                <input type="text" class="form-control input-sm" id="external_image_url">
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-12 col-xs-12">
                            <label for="external_image_download" class="label-control col-sm-2 col-xs-3"></label>
                            <div class="col-sm-10 col-xs-9">
                                <input type="button" value="下载" class="btn btn-sm btn-primary" id="external_image_download">
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>

        <div class="col-sm-3">
            <h4>Works
                <input type="button" class="btn btn-xs btn-success" data-toggle="modal" data-target="#work_modal" value="create"></h4>
            <div class="extra-wrap">
                <p style="color:#626262">
                    {% for work in works %}
                    <a href="{{url_for('work.work_page',page_id=work.id)}}" class="label label-{% if work.priority == 1 %}default
                                                  {% elif work.priority == 2 %}warning
                                                  {% else%}danger
                                                  {% endif %}">{{work.title}}</a>
                    {% endfor %}
                </p>
            </div>
        </div>

    </div>

        <div class="clear"></div>

</div>


<div id="modal-area">
    {{ modal_macros.album_modal(siteinfo) }}
    {{ modal_macros.work_modal() }}
    {{ modal_macros.edit_setting(settings) }}
</div>

{% endblock %}


{% block script %}
<script type="text/javascript">
js_work = {
    'create_album_url': "{{url_for('api.create')}}",
    'check_files_url': "{{url_for('api.task',task='check_task')}}",
    'new_setting_url': "{{url_for('api.setting_edit',label='add')}}",
    'edit_setting_url': "{{url_for('api.setting_edit',label='edit')}}",
    'scan_task_url': "{{url_for('api.task',task='scan_task')}}",
    'count_temp_url': "{{url_for('api.count_temp')}}",
    'count_recycle_url': "{{url_for('api.count_recycle')}}",
    'create_thumbnail_url': "{{url_for('api.task',task='create_thumbnail')}}",
    'delete_thumbnail_url': "{{url_for('api.task',task='delete_thumbnail')}}",
    'move_to_recycle_url': "{{url_for('api.task',task='move_to_recycle')}}",
    'add_work_url': "{{url_for('api.work_add')}}",
    'cache_clear_url': "{{ url_for('api.cache_clear') }}",
    'image_origin_url': "{{ url_for('api.image_origin_url') }}",
 }
</script>
{% endblock %}